<?php

/**
 * JingYao-backend
 *
 * @link     https://gitee.com/wang-zhihui-release/jingyao-backend
 * @apiDocument https://gitee.com/wang-zhihui-release/jingyao-backend/wikis/
 */

namespace App\Http\Controllers;

use App\Services\HomeService;
use Illuminate\Http\Request;

class HomeController extends Controller
{
    protected $homeService;

    public function __construct(HomeService $homeService)
    {
        $this->homeService = $homeService;
    }

    public function homePage()
    {
        $result = $this->homeService->home();
        return renderSuccessJson($result);
    }

    public function homeSearch(Request $request)
    {
        $title = $request->input('title');
        $page = $request->input('page', 1);
        $pageSize = $request->input('page_size', 10);
        $res = $this->homeService->homeSearch($title, $page, $pageSize);
        return renderSuccessJson($res);
    }
}
